home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / QUIZGAM.DIR / 00180_Script_GET - PUT - SET HANDLERS < prev    next >
Text File  |  1996-03-19  |  7KB  |  221 lines

  1. -- -----------------------------------------------------------------------------
  2. -- handler getQuestionForTile retrieves a questionnumber from field "questionnumbers"
  3. -- and displays the corresponding question
  4.  
  5. on getQuestionForTile aTile,qSprite,aSprite
  6.   global questionIndex,questionNumbers,QCastName,ACastName
  7.   
  8.   -- retrieve the number of the next question to ask
  9.   set index        = getItemFromLineFromVar(questionIndex,aTile,questionNumbers)
  10.   set nextQuestion = getItemFromLineFromVar(index,aTile,questionNumbers)
  11.   
  12.   -- display the question AND it's answer on stage
  13.   displayPartOfQuestionOfTile QCastName,nextQuestion,qSprite
  14.   displayPartOfQuestionOfTile ACastName,nextQuestion,aSprite
  15.   
  16. end
  17.  
  18.  
  19. -- -----------------------------------------------------------------------------
  20. -- handler getAnswerClicked returns the number of the answerButton the user
  21. -- clicked. Top button = 1.
  22.  
  23. on getAnswerClicked aClickV,aSprite,nrOfAnswers
  24.   global buttonHeight
  25.   
  26.   set castOffset = the locV of sprite aSprite
  27.   
  28.   -- determine clickLoc relative to castMember
  29.   set clickV = (aClickV - castOffset)
  30.   
  31.   --  Determine top, middle and bottom
  32.   set topOfAnswerSprite    = 0
  33.   set bottomOfAnswerSprite = the height of cast (the castNum of sprite aSprite)
  34.   set middleOfAnswerSprite = bottomOfAnswerSprite / 2
  35.   
  36.   -- 3 ANSWERS: test if the clickloc was on top, middle or bottom of cast.
  37.   if (clickV >= 0) AND (clickV <= buttonHeight) then
  38.     set answer = 1
  39.   else
  40.     if (clickV >= (middleOfAnswerSprite - (buttonHeight / 2))) AND ¼
  41. (clickV <= (middleOfAnswerSprite + (buttonHeight / 2))) then
  42.       set answer = 2
  43.     else
  44.       -- if there are 3 answers, user clicked 3; if there are 2 answers, user clicked 2
  45.       set answer = nrOfAnswers
  46.     end if
  47.   end if
  48.   
  49.   return answer
  50.   
  51. end
  52.  
  53. -- -----------------------------------------------------------------------------
  54. -- handler getStartNr returns the number of the first question for a game
  55.  
  56. on getStartNr
  57.   global nrOfQuestionsPerTile,nrOfTiles,gameNr
  58.   
  59.   if gameNr = 1 then
  60.     return 1
  61.   else
  62.     return nrOfQuestionsPerTile * nrOfTiles * (gameNr - 1) + 1
  63.   end if
  64.   
  65. end
  66.  
  67. -- -----------------------------------------------------------------------------
  68. -- handler getGameNr returns the number of the game we're currently in
  69.  
  70. on getGameNr
  71.   global gameNr
  72.   
  73.   return gameNr
  74.   
  75. end
  76.  
  77. -- -----------------------------------------------------------------------------
  78. -- handler getEndNr returns the number of the last question for a game
  79.  
  80. on getEndNr
  81.   global nrOfQuestionsPerTile,nrOfTiles,gameNr
  82.   
  83.   return nrOfQuestionsPerTile * nrOfTiles * gameNr 
  84.   
  85. end
  86.  
  87. -- -----------------------------------------------------------------------------
  88. -- handler getSourceList returns an ordered list of maxEntries items
  89.  
  90. on getSourceList startNr,endNr
  91.   set sortedlist = []  
  92.   repeat with i = startNr to endNr
  93.     add sortedlist,i
  94.   end repeat
  95.   
  96.   return sortedlist
  97. end
  98.  
  99.  
  100. -- -----------------------------------------------------------------------------
  101. -- handler getCurrentQuestion returns the question currently shown in tile aTile
  102.  
  103. on getCurrentQuestion aTile
  104.   global questionNumbers,questionIndex
  105.   
  106.   set currQuestion = getItemFromLineFromVar (questionIndex,aTile,questionNumbers)
  107.   return getItemFromLineFromVar (currQuestion,aTile,questionNumbers)
  108.   
  109. end
  110.  
  111. -- -----------------------------------------------------------------------------
  112. -- handler getCorrectAnswer returns the correct answer for a question
  113.  
  114. on getCorrectAnswer aQuestion
  115.   global correctAnswer,answers
  116.   return getItemFromLineFromVar (1,aQuestion,answers)
  117. end
  118.  
  119. -- -----------------------------------------------------------------------------
  120. -- handler getItemFromLineFromVar returns item anItem from line aLine from variable aVar
  121.  
  122. on getItemFromLineFromVar anItem,aLine,aVar
  123.   return item value(anItem) of line aLine of aVar
  124. end
  125.  
  126. -- -----------------------------------------------------------------------------
  127. -- handler putListIntoLineOfField puts the text of a question into a text field of a tile
  128.  
  129. on putListIntoLineOfField aList,aLine,aField
  130.   set lastItem = count(alist)
  131.   
  132.   repeat with currItem = 1 to lastItem
  133.     put getAt(aList,curritem) & the itemDelimiter after line aLine of field aField
  134.   end repeat
  135.   
  136.   put RETURN after line aLine of field aField
  137. end
  138.  
  139.  
  140. -- -----------------------------------------------------------------------------
  141. -- handler setSpriteVisibility sets the visible of sprite aSprite to FALSE
  142.  
  143. on setSpriteVisibility aSprite,state
  144.   set the visible of sprite aSprite to state
  145.   updateStage
  146. end
  147.  
  148. -- -----------------------------------------------------------------------------
  149. -- handler setItemOfLineOfVartoValue changes the value and returns the updated variable
  150.  
  151. on setItemOfLineOfVartoValue anItem,aLine,aVar,aValue
  152.   
  153.   put aValue into item anItem of line aLine of aVar
  154.   return aVar
  155.   
  156. end
  157.  
  158.  
  159. -- -----------------------------------------------------------------------------
  160. -- handler setPuppets sets puppetsprites
  161.  
  162. on setPuppets startSprite,endSprite,state
  163.   repeat with currSprite = startSprite to endSprite
  164.     puppetSprite currSprite, state
  165.   end repeat
  166. end
  167.  
  168. -- -----------------------------------------------------------------------------
  169. -- handler setStretch sets the stretch of sprites firstSprite to lastSprite to state
  170.  
  171. on setStretch firstSprite,lastSprite,state
  172.   repeat with currSprite = firstSprite to lastSprite
  173.     set the stretch of sprite currSprite = state
  174.   end repeat
  175. end
  176.  
  177.  
  178. -- -----------------------------------------------------------------------------
  179. -- handler getPathDelimiter returns a "\" if movie running on a PC, a "" otherwise.
  180.  
  181. on getPathDelimiter
  182.   if the machineType = 256 then
  183.     set delimiter = "\"
  184.   else
  185.     set delimiter = ":"
  186.   end if
  187.   
  188.   return delimiter
  189. end
  190.  
  191.  
  192. -- -----------------------------------------------------------------------------
  193. -- handler setSpritesVisibility sets visible of sprites containing q & answer = TRUE
  194.  
  195. on setSpritesVisibility firstSprite,lastSprite,state
  196.   repeat with currSprite = firstSprite to lastSprite
  197.     setSpriteVisibility currSprite,state
  198.   end repeat
  199. end
  200.  
  201.  
  202. -- -----------------------------------------------------------------------------
  203. -- handler getSpritePosition returns the position of sprite aSprite
  204.  
  205. on getSpritePosition aSprite
  206.   set aSpriteLocH = the locH of sprite aSprite
  207.   set aSpriteLocV = the locV of sprite aSprite
  208.   
  209.   return [aSpriteLocH,aSpriteLocV]
  210. end
  211.  
  212.  
  213. -- -----------------------------------------------------------------------------
  214. -- handler setSpriteToPosition sets sprite aSprite to location aLoc
  215.  
  216. on setSpriteToPosition aSprite,aLoc
  217.   set the locH of sprite aSprite to getAt(aLoc,1)
  218.   set the locV of sprite aSprite to getAt(aLoc,2)
  219.   updateStage
  220. end
  221.